﻿using MS.Common;
using Newtonsoft.Json;
using Prism.Commands;
using Prism.Events;
using Prism.Ioc;
using Prism.Regions;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using wpf.Triage.DataModel;

namespace wpf.Triage.ViewModels
{
    public class ComObj 
    { 
    
        public string ID { get; set; }
        public string DisText { get; set; }
    }
    public class PatientListModel : VmBase,IDialogAware
    {
        private string _ComText ;
        public string ComText
        {
            get
            {
                return _ComText;
            }
            set
            {
                _ComText = value;
                RaisePropertyChanged(nameof(ComText));
            }
        }


        private List<ComObj> _ItemList;
        public List<ComObj> ItemList
        {
            get
            {
                return _ItemList;
            }
            set
            {
                _ItemList = value;
                RaisePropertyChanged(nameof(ItemList));
            }
        }


        private List<triagelevel> _LevelList;

      

        public List<triagelevel> LevelList
        {
            get
            {
                return _LevelList;
            }
            set
            {
                _LevelList = value;
                RaisePropertyChanged(nameof(LevelList));
            }
        }
        public DelegateCommand<object> SaveCommand { get; private set; }

      
        public PatientListModel(IContainerExtension container, IEventAggregator eventAggregator, IRegionManager regionManager) : base(container, eventAggregator, regionManager)
        {
            this.SaveCommand = new DelegateCommand<object>(OnSave);
            List<triagelevel> levelList = new List<triagelevel>();
            levelList.Add(new triagelevel() { ID = "1", COLOUR = "Red", LEVELNAME = "1级", LEVELNUMBER = "1", LEVELSYMBOL = "1111" });
            levelList.Add(new triagelevel() { ID = "2", COLOUR = "Red", LEVELNAME = "2级", LEVELNUMBER = "2", LEVELSYMBOL = "2222" });
            //redisHelper.SetStringKey<List<triagelevel>>("levelList", levelList);
            LevelList = levelList;
            //LevelList = redisHelper.GetStringKey<List<triagelevel>>("levelList");

            List<ComObj> lsit1 = new List<ComObj>();
            for (int i = 0; i < 15; i++)
            {
                lsit1.Add(new ComObj() { ID=i.ToString(),DisText="名字"+i.ToString()});

            }
            ItemList = lsit1;
            ComText = "默认值";
        }

        private void OnSave(object obj)
        {
            if (string.IsNullOrEmpty(ComText))
            {

            }
        }

        public string Title { get; set; } = "";
        public event Action<IDialogResult> RequestClose;

        public bool CanCloseDialog()
        {
            return true;
        }

        public void OnDialogClosed()
        {
             
        }
        /// <summary>
        /// 打开对话框
        /// </summary>
        /// <param name="parameters"></param>
        public void OnDialogOpened(IDialogParameters parameters)
        {
            var value = parameters.GetValue<string>("type");//获取传入参数
            Title = value;
        }
    }
}
